package util

type PageInfo struct {
	List      any   `json:"list"`
	TotalPage int   `json:"totalPage"`
	Total     int64 `json:"total"`
	PageSize  int   `json:"pageSize"`
	PageNum   int   `json:"pageNum"`
}

func ToPageInfo(total int64, pageSize, pageNum int, list any) PageInfo {

	var totalPage = int(total) / pageSize

	if int(total)%pageSize != 0 {
		totalPage++
	}

	return PageInfo{
		List:      list,
		TotalPage: totalPage,
		Total:     total,
		PageSize:  pageSize,
		PageNum:   pageNum,
	}
}
